local skel = fk.CreateSkill {
  name = "rmt__zhiwen",
}

Fk:loadTranslationTable{
  ["rmt__zhiwen"] = "治文",
  [":rmt__zhiwen"] = "每轮限一次，一张牌进入中央区后，若中央区花色齐全，你可以摸手牌数张牌（至多摸五张）。",
  ["#rmt__zhiwen-invoke"] = "治文：你可以摸 %arg 张牌",
}

local DIY = require "packages.diy_utility.diy_utility"

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  times = function (_, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryRound)
  end,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and player:usedSkillTimes(skel.name, Player.HistoryRound) == 0 and not player:isKongcheng() then
      if table.find(data, function (move) return move.toArea == Card.DiscardPile end) then
        local suits = {}
        for _, id in ipairs(DIY.getCenterCards(player.room)) do
          table.insertIfNeed(suits, Fk:getCardById(id).suit)
        end
        table.removeOne(suits, Card.NoSuit)
        return #suits == 4
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = skel.name,
    prompt = "#rmt__zhiwen-invoke:::"..(math.min(player:getHandcardNum(), 5)) })
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(math.min(player:getHandcardNum(), 5), skel.name)
  end,
})

skel:addAcquireEffect(function (self, player, is_start)
  player.room:addSkill("#CenterArea")
end)


return skel
